package site.hanzhe.cnCalendar.utils;

public class CnCalendarUtil {

    /**
     * 星期转换数字
     *
     * @author 张涵哲
     * @since 2025-11-25 17:33
     */
    public static int dayOfWeekToInt(String weekOfDay) {
        return switch (weekOfDay) {
            case "星期一" -> 1;
            case "星期二" -> 2;
            case "星期三" -> 3;
            case "星期四" -> 4;
            case "星期五" -> 5;
            case "星期六" -> 6;
            case "星期日" -> 7;
            default -> throw new RuntimeException("错误的星期：" + weekOfDay);
        };
    }

    /**
     * 简化农历月份
     *
     * @author 张涵哲
     * @since 2025-11-25 18:16
     */
    public static String simplifyLunarMonth(String lunarMonth) {
        String month = lunarMonth.replaceAll("閏", "");
        return switch (month) {
            case "十一月" -> "冬";
            case "十二月" -> "腊";
            default -> month.replace("月", "");
        };
    }

    public static String simpleChineseSolarTerm(String lunarMonth) {
        if (lunarMonth == null) return null;
        return switch (lunarMonth) {
            case "驚蟄" -> "惊蛰";
            case "穀雨" -> "谷雨";
            case "小滿" -> "小满";
            case "芒種" -> "芒种";
            case "處暑" -> "处暑";
            default -> lunarMonth;
        };
    }

}
